//
//  NSArray+VOCExtentions.m
//  iVoc
//
//  Created by Wallace Wu on 09-3-31.
//  Copyright 2009 Sonic Solutions. All rights reserved.
//

#import "NSArray+VOCExtentions.h"
#import "VOCWordData.h"

@implementation NSArray(VOCExtentions)
-(NSArray*)filteredWordsWithLanguage:(VOCWORDLanguage)lang
{
    NSMutableArray *result = [[[NSMutableArray alloc] init] autorelease];
    
    for (VOCWordData *word in self) {
        if(word.kind == lang)
        {
            [result addObject:word];
        }
    }
    
    return [[result copy] autorelease];
}

-(NSArray*)filteredWordsWithExplantionLanguage:(VOCWORDLanguage)lang
{
    NSMutableArray *result = [[[NSMutableArray alloc] init] autorelease];
    
    for (VOCWordData *word in self) {
        for (VOCWordExp *exp in word.explanations) {
            if(exp.kind == lang)
            {
                [result addObject:word];
                break;
            }
        }
    }
    
    return [[result copy] autorelease];
}

-(NSArray*)filteredExplanationsWithLanguage:(VOCWORDLanguage)lang
{
    NSMutableArray *result = [[[NSMutableArray alloc] init] autorelease];
    
    for (VOCWordExp *exp in self) {
        if(exp.kind == lang)
        {
            [result addObject:exp];
        }
    }
    
    return [[result copy] autorelease];
}
@end
